package com.lazy.mongo.shw;

import java.net.UnknownHostException;

import org.slf4j.Logger;

import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.MongoClient;

public class MongoDb {

    private static MongoDb instance;

    private DB db;

    private MongoDb(){
        // MongoClient mongoClient = new MongoClient();
        // MongoClient mongoClient = new MongoClient( "localhost" );
        // MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
        MongoClient mongoClient;
        try{
            mongoClient = new MongoClient("192.168.1.55", 10002);
            // mongoClient = new MongoClient(Arrays.asList(new ServerAddress("192.168.0.228", 27017)));
            db = mongoClient.getDB("gwgps");
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public static MongoDb getInstance(){
        if(instance == null){
            instance = new MongoDb();
        }
        return instance;
    }

    public DB getDb(){
        return this.db;
    }
    
}
